// 字典管理接口
import request from '@/utils/request'
import type { DictResData } from './dictType'

enum API {
  get_dict_code = '/api/dict/code/',
  get_dict_parentCode = '/api/dict/list',
  add_dict = '/api/dict/add',
  update_dict = '/api/dict/update',
  set_logo = '/api/dict/setlogo',
  get_logo = '/api/dict/logo',
}
// 根据code获取字典
export const reqGetDictByCode = (code: string) => {
  return request.get<any,any>(API.get_dict_code + code)
}
// 根据parentCode获取字典 //00000默认根节点,查询全部字典列表
export const reqGetDictByParentCode = (parentCode: string) => {
  return request.get<any,any>(API.get_dict_parentCode + `?parentCode=${parentCode}`)
}
// 新增/编辑字典
export const reqAddOrUpdateDict = (data: any) => {
  if (data.id) {
    return request.put<any,any>(API.update_dict, data)
  } else {
    return request.post<any,any>(API.add_dict, data)
  }
}
// 设置项目logo
export const reqSetLogo = (file: any) => {
  return request.post<any,any>(API.set_logo, file)
}
// 查询项目logo
export const reqGetLogo = () => {
  return request.get<any,any>(API.get_logo)
}